package com.smartwheel.db.mongo;

import java.net.UnknownHostException;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;


public class DbConnection {
	
	private static final Logger LOG = LoggerFactory.getLogger(DbConnection.class);
	private static DB db;
	
	private String host;
	private int port;
	private String dbname;
	

	public void init() {
		db  = null;
		try {
			MongoClient mongoClient = new MongoClient();
			db = mongoClient.getDB(dbname);
		} catch (UnknownHostException e) {
			LOG.error(e.getMessage());
		}
	}


	public static DBCollection getCollection(String colName) {
		return db.getCollection(colName);
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getDbname() {
		return dbname;
	}

	public void setDbname(String dbname) {
		this.dbname = dbname;
	}
} 
